package com.sims.action.student;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import com.sims.bean.Student;
import com.sims.bean.StudentPosition;
import com.sims.service.StudentService;
import com.sims.util.ActionEnhanced;
import com.sims.util.Constant;
import com.sun.org.apache.bcel.internal.generic.NEW;

@SuppressWarnings("serial")
public class FindStudentBasicInfoAction extends ActionEnhanced{

	private Student student = new Student() ;
	private StudentPosition studentPosition =new StudentPosition();
	private String birthday;

	@Autowired
	private StudentService studentService;

	public Student getStudent() {
		return student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	public StudentPosition getStudentPosition() {
		return studentPosition;
	}

	public void setStudentPosition(StudentPosition studentPosition) {
		this.studentPosition = studentPosition;
	}
	
	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	HttpSession session = ServletActionContext.getRequest().getSession();

	@Override
	public String execute() {

		result = studentService.findStudentBasicInfo(student, studentPosition);
		setBirthday(student.getBirthday().toString().substring(0, 10));
		if (result.containsKey(Constant.SUCCESS)) {
			System.out.println("success");
			return SUCCESS;
		}
		// System.out.println("error");
		return ERROR;
	}
}
